﻿
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Ease Template Manual - SYSTN.COM</title>
<style>
<!--

td { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px; color:#000000   }
.style8 {
background-color: #FFFFFF;
}

p { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px; color:#000000   }
.style10 {
font-size: 9px;
font-family: "Arial Unicode MS";
text-align: right;
}
-->
</style>
</head>

<table class="style4" style="WIDTH: 100%" cellSpacing="0" cellPadding="0" border="0" id="table1">
	<tr>
		<td class="style8">
		<table style="WIDTH: 100%" cellSpacing="8" cellPadding="8" border="0" id="table2">
			<tr>
				<td style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">
				<table id="table3" style="BORDER-COLLAPSE: collapse" borderColor="#808080" cellPadding="4" width="100%" align="left" border="0">
					<tr>
						<td vAlign="top" colSpan="2" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">
						<font style="FONT-SIZE: 30px" color="#94a7b1">
						<font face="Arial">Ease Template Manual</font> </font>
						<font style="FONT-SIZE: 10px" face="Arial" color="#94a7b1">
						Version:E3</font></td>
					</tr>
					<tr>
						<td vAlign="top" width="4" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">　</td>
						<td vAlign="top" align="left" width="98%" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">
						<table class="TableBorder" cellSpacing="1" cellPadding="0" width="100%" border="0" id="table5">
							<tr>
								<td class="TableMiddle">嵌套循环应该是开发菜单中最常用到的循环方式，用过phplib的用户都知道写起来是多么麻烦。记得曾经在phpe.net上看过phplib写嵌套循环的方法，当时实在是在令我头大。现在你看了Ease 
								Template这篇介绍嵌套循环方式的解说后，定会觉得原来写程序也可以这么简单。废话少说，让我们来一起试验。<br>
								<br>
								在php程序中建立了两个数组，分别是分类$cate，以及子类$sucate，我们会将子类的数组对应分类数组进行排列，达到嵌套循环的效果。<br>
								<br>
								test_6.php<br>
　<ol style="text-align: left; margin: 0px; padding-left: 40px; padding-right: 1px; padding-top: 1px; padding-bottom: 1px; background: #e1e7f0">
									<li style="background: #ffffff url('images/code_bg.gif')">
									<code><span style="COLOR: #000000">
									<span style="COLOR: #0000bb">&lt;?php &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #007700">include</span><span style="COLOR: #dd0000">&quot;./template.ease.php&quot;</span><span style="COLOR: #007700">; 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">$tpl&nbsp;</span><span style="COLOR: #007700">=&nbsp;new&nbsp;</span><span style="COLOR: #0000bb">template</span><span style="COLOR: #007700">(); 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #ff8000">//分类数组 &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">$cate&nbsp;</span><span style="COLOR: #007700">=&nbsp;array(</span><span style="COLOR: #dd0000">'分类1'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'分类2'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'分类3'</span><span style="COLOR: #007700">); 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #ff8000">//子类数组 &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">$subcate&nbsp;</span><span style="COLOR: #007700">=&nbsp;array( 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="COLOR: #dd0000">'计算机'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'报纸'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'杂志'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'鼠标'</span><span style="COLOR: #007700">), 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="COLOR: #dd0000">'青菜'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'白菜'</span><span style="COLOR: #007700">), 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(</span><span style="COLOR: #dd0000">'橘子'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'香蕉'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">'苹果'</span><span style="COLOR: #007700">) 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;); &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">$tpl</span><span style="COLOR: #007700">-&gt;</span><span style="COLOR: #0000bb">set_file</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">'test_6'</span><span style="COLOR: #007700">); 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">$tpl</span><span style="COLOR: #007700">-&gt;</span><span style="COLOR: #0000bb">p</span><span style="COLOR: #007700">(); 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									</span><span style="COLOR: #0000bb">?&gt;</span>
									</span></code></li>
								</ol>
								<br>
								<br>
								现在我们来讲解Ease Template在模板中嵌套循环的方法。首先是循环$cate，然后通过调用循环$cate的循环id:$ck赋值给$subcate就得到了子类循环数据，再列出子类的数值即可实现嵌套循环。<br>
								<br>
								test_6.htm<br>
　<ol style="text-align: left; margin: 0px; padding-left: 40px; padding-right: 1px; padding-top: 1px; padding-bottom: 1px; background: #e1e7f0">
									<li style="background: #ffffff url('images/code_bg.gif')">
									<code><span style="COLOR: #000000">嵌套循环:&lt;br&gt; 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&lt;table&nbsp;border=&quot;1&quot;&nbsp;width=&quot;300&quot;&nbsp;bordercolor=&quot;#C0C0C0&quot;&gt; 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									<font color="#808080">
									&lt;!--&nbsp;$cate&nbsp;AS&nbsp;$ck=&gt;$cv&nbsp;--&gt;</font> &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&lt;tr&gt; &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;<font color="#007700">{cv}</font>&lt;/b&gt;&lt;/td&gt; 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&lt;/tr&gt; &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;<font color="#808080">&lt;!--&nbsp;$subcate[$ck]&nbsp;AS&nbsp;$K=&gt;$V&nbsp;--&gt;</font> 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt; &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&amp;nbsp;&amp;nbsp;-&gt;<font color="#007700">{V}</font>&lt;/td&gt; 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt; &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&nbsp;&nbsp;<font color="#808080">&lt;!--&nbsp;END&nbsp;--&gt;</font> 
									&nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									<font color="#808080">&lt;!--&nbsp;END&nbsp;--&gt;</font> &nbsp;
									</li>
									<li style="background: #ffffff url('images/code_bg.gif')">
									&lt;/table&gt;</span> </code></li>
								</ol>
								<br>
								<br>
								看到这里你应该明白Ease Template对嵌套循环的做法了吧。还有更多惊喜在后面等你。。。^ 
								: ^</td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="style8" style="HEIGHT: 21px">
		<table class="style4" cellSpacing="0" cellPadding="0" align="right" id="table6">
			<tr>
				<td style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">
				<img height="13" src="images/copyright_left.gif" width="3"></td>
				<td class="style10" style="WIDTH: 240px" background="images/copyright_bg.gif">
				Copyright 2005 - 2008 <a href="http://www.systn.com" target="_blank"><font color="#000000">SYSTN.COM</font></a>&nbsp;&nbsp;&nbsp;</td>
				<td style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #000000">
				<img height="13" src="images/copyright_right.gif" width="2"></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
